<template>
	<view class="register">
		<view class="title">
			<view>欢迎注册登入</view>
		</view>
		<view class="form">
			<input type="text" v-model="username" placeholder="请输入用户名" />
			<input type="text" v-model="password" placeholder="请输入密码" />
		</view>
		<view class="btn">
			<button @tap="add">立即注册</button>
			<view class="tip">
				<text class="tip" @tap="tologin">前往登入</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: "",
				password: ""
			}
		},
		methods: {
			add() {
				uniCloud.callFunction({
					name: "adduser",
					data: {
						username: this.username,
						password: this.password
					},
					success: (res) => {
						console.log(res)
						if (res.result.code == 200) {
							uni.showToast({
									title: "注册成功",
									icon: "success"
								}),
								uni.navigateBack();
						}
					}
				})
			},
			tologin() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}
		}
	}
</script>

<style>
	.register {
		padding: 130rpx 40rpx 0;
		background-size: 100% 100%;
		height: 100vh;
	}

	.title {
		font-weight: bold;
		font-size: 40rpx;

	}

	.form {

		margin-top: 120rpx;

		input {
			border-bottom: 1px solid #d6d6d6;
			margin-bottom: 40rpx;
		}
	}

	.btn {
		margin-top: 100rpx;

		button {
			background-color: #00b300;
			color: white;
		}

		.tip {
			text-align: right;
			color: #b9b9b9;
			margin-top: 20rpx;
		}
	}
</style>